package com.fis.mca.admin;

import java.io.Serializable;
import java.util.Vector;

import com.fss.util.CollectionUtil;

public class AppUser implements Serializable
{
	private String userName;
	private boolean loggedIn;
	
	private Vector vtPermission = new Vector();
	
	public AppUser(){}
	
	public AppUser(String userName, boolean loggedIn)
	{
		super();
		this.userName = userName;
		this.loggedIn = loggedIn;
	}

	public String getUserName()
	{
		return userName;
	}

	public void setUserName(String userName)
	{
		this.userName = userName;
	}

	public boolean isLoggedIn()
	{
		return loggedIn;
	}

	public void setLoggedIn(boolean loggedIn)
	{
		this.loggedIn = loggedIn;
	}

	public String getPermission(String strModuleName)
	{
		if (vtPermission == null || vtPermission.size() == 0)
			return "";
		Vector vtValue = CollectionUtil.filterSorted2DVector(vtPermission,
				new Object[]{ strModuleName }, new int[]{ 0 });
		String strReturn = "";
		for (int i = 0; i < vtValue.size(); i++)
			strReturn += (String) ((Vector) vtValue.elementAt(i)).elementAt(1);
		return strReturn;
	}
	
	public void setPermissionInfo(Vector vtValue) throws Exception
	{
		if (vtValue == null)
		{
			vtValue = new Vector();
		}
		CollectionUtil.sort2DVector(vtValue, new int[]{ 0, 1 });
		vtPermission = vtValue;
	}
	
	public void clearPermissionInfo()
	{
		vtPermission = new Vector();
	}
}
